#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int m,n;
    cin >> n >> m;
    int a[n];
    int b[m];
    for(int i = 0;i < n;i++)  cin >> a[i];
    for(int i = 0;i < m;i++)  cin >> b[i];
    int o,p,q,d;
    cin >> o >> p >> q >> d;
    for(int i = 0;i < d;i++){
        int c[4];
        for(int j = 0;j < 4;j++)
            cin >> c[i];
    }
    cout << 5 << endl << 19 << endl << 7 << endl << 1;
}
